import {commGet, deleteAction,commPost,commPut} from "@utils/service/index.js";

/**
 * 获取字典列表
 * @param data
 * @returns {Promise<* extends (object & {then(onfulfilled: infer F, ...args: infer _): any}) ? (F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never) : *>}
 */
export function getDictList(data) {
    return commGet({
        url: "sys/dict/list",
        method: 'get',
        data
    })
}

/**
 * 新增字典
 * @param data
 * @returns {Promise<* extends (object & {then(onfulfilled: infer F, ...args: infer _): any}) ? (F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never) : *>}
 */
export function addDict(data) {
    return commPost({
        url: "/sys/dict/add",
        method: 'post',
        data
    })
}

/**
 * 编辑字典
 * @param data
 * @returns {Promise<* extends (object & {then(onfulfilled: infer F, ...args: infer _): any}) ? (F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never) : *>}
 */
export function editDict(data) {
    return commPost({
        url: "/sys/dict/edit",
        method: 'post',
        data
    })
}

/**
 * 删除字典
 * @param url
 * @param data
 * @returns {Promise<T>}
 */
export function deleteDict(url,data) {
    return deleteAction({
        url: url,
        data
    })
}

/**
 * 获取删除字典列表
 * @param data
 * @returns {Promise<* extends (object & {then(onfulfilled: infer F, ...args: infer _): any}) ? (F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never) : *>}
 */
export function getDeleteList(data) {
    return commGet({
        url: "/sys/dict/deleteList",
        method: 'get',
        data
    })
}

/**
 * 取回字典
 * @param data
 * @returns {Promise<unknown extends (null | undefined) ? unknown : (unknown extends (object & {then(onfulfilled: infer F, ...args: infer _): any}) ? (F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never) : unknown)>}
 */
export function getBackDict(data,id) {
    return commPut({
        url: `/sys/dict/back/${id}`,
        method: 'put',
        data
    })
}

/**
 * 获取字典项列表
 * @param data
 * @returns {Promise<* extends (object & {then(onfulfilled: infer F, ...args: infer _): any}) ? (F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never) : *>}
 */
export function getDictItemList(data) {
    return commGet({
        url: "sys/dictItem/list",
        method: 'get',
        data
    })
}

/**
 * 新增字典项
 * @param data
 * @returns {Promise<* extends (object & {then(onfulfilled: infer F, ...args: infer _): any}) ? (F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never) : *>}
 */
export function addDictItem(data) {
    return commPost({
        url: `sys/dictItem/add`,
        method: 'post',
        data
    })
}

/**
 * 编辑字典项
 * @param data
 * @returns {Promise<* extends (object & {then(onfulfilled: infer F, ...args: infer _): any}) ? (F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never) : *>}
 */
export function editDictItem(data) {
    return commPut({
        url: `/sys/dictItem/edit`,
        method: 'put',
        data
    })
}

/**
 * 查询字典
 * @param data
 * @returns {Promise<* extends (object & {then(onfulfilled: infer F, ...args: infer _): any}) ? (F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never) : *>}
 */
export function getManyDictItems(data) {
    return commGet({
        url: `/sys/api/getManyDictItems`,
        method: 'get',
        data
    })
}

